<?php
class indexController extends Controller{
    public function __construct(){
        parent::__construct();

		$this->template->assign(array(
			'userid'=>100,
		));
    }

    public function index($tpl){
        echo 'welcome';

    }

    public function hello($tpl){
        echo 'hello';
    }
    
    public function valid(){
        $data=array(
            //'goods_name'=>111,
        );
        $rules=array(
            array('goods_name',1,'必须有商品名','require'),
        );
        $validation=new Validation($data,$rules);
        if(!$validation->valid()){
            echo $validation->get_error();
        }
    }
	public function tpl_test(){
		// include $tpl;
		$data=array(
			array('title'=>'aaa','content'=>'bbb'),
			array('title'=>'bbb','content'=>'bbb'),
		);
		
		$username='张三';
		
		$tag=true;
		
		include template(get_defined_vars());
	}
	
	//think-template 测试

	public function demo(){
		$data=array(
			array('title'=>'aaa','content'=>'bbb'),
			array('title'=>'bbb','content'=>'bbb'),
		);
		
		
		$this->tpl(get_defined_vars());
	}
	//think-orm 测试
	public function demo2(){
		// $data=\think\Db::name('member')->select();
		// print_r($data);
		
		// \think\Db::name('member')->insert(array(
		// 	'username'=>time(),
		// 	'password'=>rand(),
		// ));
		
		// $member_model=load_model('member');
		// var_dump($member_model->select());

		$admin_model=M('admin');
	}

} 
